package Com.Hupochuan.Dal.Tab;

import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

import Com.Hupochuan.Dal.DBManager.DBManager;
import Com.Hupochuan.Vo.MovieType;

public class MovieTypeTab {
	/*
	 * 本类私有对象
	 */
	private DBManager<MovieType> dbManager = new DBManager<MovieType>(MovieType.class);
	
	/*
	 * 单一实例
	 */
	private MovieTypeTab(){}
	private static MovieTypeTab movieTypeTab = new MovieTypeTab();
	public static MovieTypeTab getObject(){
		return movieTypeTab;
	}
	
	/*
	 * 电影演员列表
	 */
	public List<MovieType> findMovieTypeList(long movieId){
		
		//参数部分
		List<MovieType> movieTypeList = new Vector<MovieType>();
		StringBuffer sqlBuff = new StringBuffer();
		Hashtable<String,Object> paraHash = new Hashtable<String,Object>();
		
		//sql语句部分
		sqlBuff.append(" select MovieType.*, ");
		sqlBuff.append(" 	Type.name as typeName ");
		sqlBuff.append(" from MovieType ");
		sqlBuff.append(" left join Type on MovieType.typeId=Type.id ");
		sqlBuff.append(" where MovieType.movieId=${movieId} ");
		sqlBuff.append(" order by ");
		sqlBuff.append(" 	MovieType.weight desc, ");
		sqlBuff.append(" 	Type.weight desc, ");
		sqlBuff.append(" 	Type.id, ");
		sqlBuff.append(" 	MovieType.id ");
		
		//sql参数部分
		paraHash.put("movieId",movieId);
		
		//执行sql 
		movieTypeList = this.dbManager.querySqlReturnVoList(sqlBuff.toString(),paraHash);
		
		//返回列表
		return movieTypeList;
	}
}
